종류 | 모형 |
단순회귀 | 1개의 독립변수와 반응변수가 직선(선형) 관계 |
다중회귀 | k개의 독립변수와 반응변수가 선형 관계 |
다항회귀 | k개의 독립변수가 반응변수가 2차 함수 이상의 관계 |
비선형회귀 | 회귀식의 미지의 모수들과 선형관계가 아닌 경우(지수함수, 로그함수, 삼각함수 등) |
> X<-c(1, 1.4, 1.6, 2, 2.2, 2.4, 3, 3.3, 3.6)
> Y<-c(15, 13, 13, 12, 11, 10.5, 10, 9, 8)
> result<-lm(Y~X) # lm은 linear model을 의미한다.
> summary(result)
Call:
lm(formula = Y ~ X)
Residuals:
Min 1Q Median 3Q Max
-0.47990 -0.41705 0.04524 0.21353 0.60809
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 16.8291 0.4142 40.63 1.43e-09 ***
X -2.4371 0.1707 -14.27 1.97e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4277 on 7 degrees of freedom
Multiple R-squared: 0.9668, Adjusted R-squared: 0.962
F-statistic: 203.7 on 1 and 7 DF, p-value: 1.97e-06
> X<-c(1, 1.4, 1.6, 2, 2.2, 2.4, 3, 3.3, 3.6)
> Y<-c(15, 13, 13, 12, 11, 10.5, 10, 9, 8)
> result<-lm(Y~X)
> anova(result)
Analysis of Variance Table
Response: Y
Df Sum Sq Mean Sq F value Pr(>F)
X 1 37.275 37.275 203.73 1.97e-06 ***
Residuals 7 1.281 0.183
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> yard<-c(31, 31, 27, 39, 30, 32, 28, 23, 28, 35)
> area<-c(58, 51, 47, 35, 48, 42, 43, 56, 41, 41)
> park<-c(1, 1, 5, 5, 2, 4, 5, 1, 1, 3)
> dist<-c(492, 426, 400, 125, 443, 412, 201, 362, 192, 423)
> price<-c(12631, 12084, 12220, 15649, 11486, 12276, 15527, 12666, 13180, 10169)
> result<-lm(price~yard+area+park+dist)
> summary(result)
Call:
lm(formula = price ~ yard + area + park + dist)
Residuals:
1 2 3 4 5 6 7 8 9 10
211.9 193.4 -451.5 -193.6 247.8 801.9 387.0 -486.6 100.3 -810.6
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 3045.689 4084.218 0.746 0.48939
yard 117.922 65.779 1.793 0.13300
area 230.563 61.193 3.768 0.01305 *
park 436.801 155.508 2.809 0.03760 *
dist -16.446 2.489 -6.609 0.00119 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 645.3 on 5 degrees of freedom
Multiple R-squared: 0.9184, Adjusted R-squared: 0.8531
F-statistic: 14.07 on 4 and 5 DF, p-value: 0.006267